/**
 * 
 */
package dt.inlee.common.vo;

import java.io.Serializable;

/**
 * @功能说明：Grid分页控件封装Bean
 * @作者： 印鲜刚
 * @创建日期： 2010-5-11
 * @
 */
@SuppressWarnings("serial")
public class PageBean implements Serializable {
	// 每页显示的行数
	private int pageSize;
	//请求的当前页
	private int curPage;
	//总页数
	private int totalPages;
	//总记录数
	private int totalRecords;
	//排序字段
	private String orderBy;
	//排序方式
	private String order="asc";

	/**
	 * 初始化PageBean相关参数
	 * @param totalRecords
	 */
	public void init(int totalRecords) {
		this.totalRecords = totalRecords;
		this.pageSize = this.pageSize == 0 ? 10 : this.pageSize;
		this.curPage = this.curPage == 0 ? 1 : this.curPage;
		if (this.getTotalRecords() > 0)
			this.setTotalPages((this.getTotalRecords() - 1) / this.getPageSize() + 1);
		if (this.getCurPage() > this.getTotalPages())
			this.setCurPage(this.getTotalPages());
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getCurPage() {
		return curPage;
	}

	public void setCurPage(int curPage) {
		this.curPage = curPage;
	}

	public int getTotalPages() {
		return totalPages;
	}

	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}

	public int getTotalRecords() {
		return totalRecords;
	}

	public void setTotalRecords(int totalRecords) {
		this.totalRecords = totalRecords;
	}

	public String getOrderBy() {
		return orderBy;
	}

	public void setOrderBy(String orderBy) {
		this.orderBy = orderBy;
	}

	public String getOrder() {
		return order;
	}

	public void setOrder(String order) {
		this.order = order;
	}
}
